/*
 *  campaign.cpp
 */

#include <string>
#include <vector>
#include "campaign.h"
#include "image.h"
#include "level.h"

Campaign::Campaign(int campaignID,
                   std::string name,
                   Image* img,
                   int difficulty,
                   int min_players,
                   Level* levels[],
                   int levels_size) : levels() {
    this->campaignID = campaignID;
    this->name = name,
    this->img = img;
    this->difficulty = difficulty;
    this->min_players = min_players;
    for (int i = 0; i < levels_size; ++i) this->levels.push_back(levels[i]);
}

Campaign::~Campaign() {
    for (int i = 0; i < levels.size(); ++i) delete levels[i];
}

int Campaign::getID() {
    return campaignID;
}

std::string Campaign::getName() {
    return name;
}

Image* Campaign::getImage() {
    return img;
}

int Campaign::getDifficulty() {
    return difficulty;
}

int Campaign::getMinPlayers() {
    return min_players;
}

int Campaign::getLevelsSize() {
    return levels.size();
}

Level* Campaign::nextLevel() {
    if (currentLevelID == -1) return levels[++currentLevelID];
    Level* nextLevel = NULL;
    for (int i = 0; i < levels.size(); ++i) {
        if (levels[i]->getID() == currentLevelID && i < (levels.size()-1)) {
            nextLevel = levels[++currentLevelID];
            break;
        }
    }
    return nextLevel;
}

//{+}

